package com.example.aicooking.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.aicooking.entity.Post;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PostMapper extends BaseMapper<Post> {
    @Select("SELECT p.* ,u.nickName,u.avatar FROM post p " +
            "JOIN user u ON p.user_id = u.user_id " +
            "WHERE u.user_id = #{userId} " +
            "ORDER BY p.create_time DESC LIMIT 20")
    List<Post> getFollowPosts(@Param("userId") String userId);
}